package com.server.questionbank.snframe.controller.Course;

import com.server.questionbank.snframe.domain.Course.Type.CourseDifficulty;
import com.server.questionbank.snframe.domain.Course.Type.CourseLabel;
import com.server.questionbank.snframe.domain.Course.Type.CourseType;
import com.server.questionbank.snframe.domain.ResDTO.ResponseResult;
import com.server.questionbank.snframe.service.CourseService.CourseTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/course/overt/type")
public class CourseTypeController {
    @Autowired
    CourseTypeService courseTypeService;

    // 获取所有课程类型
    @PostMapping("/findType")
    public ResponseResult<List<CourseType>> getAllCourseType(){
        return ResponseResult.success(courseTypeService.getAllCourseType());
    }

    // 根据类型id列表获取标签
    @PostMapping("/findLabelByTypeList")
    public ResponseResult<List<CourseLabel>> getAllCourseLabelByTypeIdList(@RequestBody Map<String, List<Long>> map){
        return ResponseResult.success(courseTypeService.getCourseLabelByTypeIdList(map.get("typeIdList")));
    }

    // 获取难度
    @PostMapping("/findDifficulty")
    public ResponseResult<List<CourseDifficulty>> findDifficulty(@RequestBody Map<String, Long> map){
        Long difficultyId = map.get("difficultyId");
        return ResponseResult.success(courseTypeService.getCourseDifficulty(difficultyId));
    }
}
